import { defineConfig } from 'vite'
import { resolve } from 'path'

const pkg = require('./package.json')
const outro = `typeof console !== 'undefined' && console.log && console.log('${pkg.name} v${pkg.version}');`

export default defineConfig({
    build: {
        lib: {
            // Could also be a dictionary or array of multiple entry points
            entry: resolve(__dirname, './src/main.ts'),
            name: 'tsthree',

            // the proper extensions will be added
            // fileName: 'tsthree',
            // formats: ['umd'],// 默认是 ['es', 'umd']
        },
        minify: false,
        rollupOptions: {
            // 确保外部化处理那些你不想打包进库的依赖
            external: [],
            output: {
                outro: outro
                // // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
                // globals: {
                //     three: 'THREE',
                // },
            },
        },
    },
})